﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Genuilder.Extensibility.Tests
{
	public class MockCodeItem : MemoryCodeItem
	{
		public MockCodeItem(string content, string fileName, CodeItemState initialState)
			: base(content, fileName, initialState)
		{

		}
		public bool Exist
		{
			get;
			set;
		}
		public bool Modified
		{
			get;
			set;
		}
	}
	public class MockCodeRepository : CodeRepositoryBase
	{
		private readonly List<CodeItemHistory> _Histories = new List<CodeItemHistory>();
		public List<CodeItemHistory> Histories
		{
			get
			{
				return _Histories;
			}
		}
		protected override CodeItem CreateCodeItem(string fileName, CodeItemState state)
		{
			return new MockCodeItem("", fileName, state);
		}

	

		
		
		protected override IEnumerable<CodeItemHistory> GetCodeItemHistories()
		{
			return _Histories;
		}

		public override IEnumerable<string> RootSourceItemNames
		{
			get
			{
				return _Histories.Select(h => h.ItemName);
			}
		}

		public override IEnumerable<string> GeneratedSourceItemNames
		{
			get
			{
				return new string[0];
			}
		}

		public override CodeItemHistory GetTransition(CodeItem item)
		{
			return _Histories.FirstOrDefault(h => h.ItemName == item.Name);
		}
	}
}
